import React from 'react'
import { withRouter } from 'react-router-dom';
import { Toast, Button, Icon, Tools,Modal } from "weaver-mobile";
import '../../../../style/qrLogin.less';

const getLabel = Tools.getLabel;
const {alert} = Modal ;

@withRouter
export default class TestCaButton extends React.Component{

    render(){
        return (
           <Button type='primary' onClick={()=> this.scan()}>{'ca'+getLabel('34234','扫一扫')}</Button>
        )
    }

    scan = ()=>{
        const em = window.em 
        if(em && em.checkJsApi('scanQRCode')){
            em.scanQRCode({
                scanType:['qrCode'],
                success:(res) =>{
                    const pr = res.resultStr.split(',').join('&').split(':').join('=').replace('ecologylogin','loginkey') ;
                    alert('success',pr) 
                    this.props.history.push('/testQrLoginCa?'+pr) 
                }
            })
        }else{
            alert('error','err:-900')
        }
    }
}